const esbuild = await import('esbuild')

let result

let js = `
    import Button from './button'
    let button = <><Button>Click me</Button></>
    render(button)
`

result = esbuild.transformSync(js, {
    loader: 'jsx',
})

console.log(result)

/*
{
  warnings: [],
  code: 'import Button from "./button";\n' +
    'let button = \/* @__PURE__ *\/ React.createElement(React.Fragment, null, \/* @__PURE__ *\/ React.createElement(Button, null, "Click me"));\n' +
    'render(button);\n',
  map: ''
}
*/

result = esbuild.transformSync(js, {
    loader: 'jsx',
    jsxFactory: 'h',
    jsxFragment: 'Fragment',
})

console.log(result)

/*
{
  warnings: [],
  code: 'import Button from "./button";\n' +
    'let button = \/* @__PURE__ *\/ h(Fragment, null, \/* @__PURE__ *\/ h(Button, null, "Click me"));\n' +
    'render(button);\n',
  map: ''
}
*/
